<template>
  <div class="videos-container">
    <div class="banner-container">
      <div class="banner-btn">
        <div class="prev"></div>
        <div class="next"></div>
      </div>
      <swiper
        :navigation="navigationOptions"
        loop>
        <swiper-slide v-for="item in [...Array(3).keys()]" :key="item" class="banner-item">
          <img src="../assets/img/banner.png" alt="">
        </swiper-slide>
      </swiper>
    </div>
    <ul class="videos-list">
      <li v-for="item in [...Array(10).keys()]" :key="item">
        <a :href="videoItem.videoSrc">
          <img src="../assets/img/videoitem.png" alt="" />
          <h2>{{ videoItem.title }}</h2>
        </a>
      </li>
    </ul>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive } from "vue";
import SwiperCore, { Navigation } from "swiper";
import { Swiper, SwiperSlide } from "swiper/vue";
import "swiper/swiper.less";
import "swiper/components/navigation/navigation.less";

SwiperCore.use([Navigation]);

export default defineComponent({
  name: "VideoShow",
  components: {
    Swiper,
    SwiperSlide
  },
  setup() {
    let videoItem = reactive(
      {
        videoSrc: "https://www.bilibili.com/video/BV1db4y117Q1",
        title: "板绘天才伦勃朗-6小时笔下的 一名老翁的肖像，竟能如此板绘天才伦勃朗-6小时笔下的 一名老翁的肖像，竟能如此",
        thumbnail: "../assets/img/videoitem.png"
      });

    let navigationOptions = {
      nextEl: ".banner-btn>.next",
      prevEl: ".banner-btn>.prev"
    };

    return {
      videoItem,
      navigationOptions
    };
  }
});
</script>

<style lang="less" scoped>
.container {
  .banner-container {
    position: relative;
    width: 100%;
    min-height: 120px;
    max-height: 360px;
    border-radius: 12px;
    overflow: hidden;

    .banner-item {
      img {
        width: 100%;
        max-height: 100%;
      }
    }

    .banner-btn {
      position: absolute;
      z-index: 999;
      bottom: 15px;
      right: 26px;
      display: flex;

      .next,
      .prev {
        width: 18.75px;
        height: 18.75px;
        border-radius: 3.75px;
        margin-left: 9px;
      }

      .prev {
        background: #B8B8B8AB url("../assets/icon/vector-left.svg") center/30% no-repeat;
      }

      .next {
        background: #B8B8B8AB url("../assets/icon/vector-right.svg") center/30% no-repeat;
      }
    }
  }

  .videos-list {
    list-style: none;
    display: grid;
    grid-template-columns: calc(50% - 6px) calc(50% - 6px);
    grid-column-gap: 12px;
    margin-top: 15px;

    li {
      margin-bottom: 10px;

      a {
        text-decoration: none;
        color: #212121;
        display: block;

        img {
          width: 100%;
        }

        h2 {
          /* autoprefixer: off */
          font-size: 13px;
          line-height: 16px;
          font-weight: 400;

          display: -webkit-box;
          overflow: hidden;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          text-overflow: ellipsis;
        }
      }
    }
  }
}
</style>
